package com.lc;

import com.lc.demo.Stock;
import com.lc.demo.User;
import com.lc.demo.UserDAO;
import com.lc.proxy.DaoProxyFactory;

import java.util.*;


public class Main {

    /*public static void main(String[] args) {
        Scanner smy = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        System.out.println("开始输入..");
        while (smy.hasNext()) {
            String arrStr = smy.next();
            obtainIntArray(list, arrStr);
            //数组排序
            Collections.sort(list);
            obtainMinResult(list);
        }
        obtainMinResult(list);
    }*/

    public static void obtainMinResult(List<Integer> list) {

        Integer one = list.get(0);
        Integer two = list.get(1);
        Integer three = list.get(2);
        if (one < 10 && two < 10 && three < 10) {
            System.out.println(one + "" + two + "" + three);
        } else {
            obtainMinValue(one, two, three);
        }
    }

    private static void obtainMinValue(Integer one, Integer two, Integer three) {
        Map<Integer, Integer> sortMap = new HashMap<>();
        String oneStrPrefix = one.toString().substring(0, 1);
        String twoStrPrefix = two.toString().substring(0, 1);
        String threeStrPrefix = three.toString().substring(0, 1);
        Integer onePrefix = Integer.parseInt(oneStrPrefix);
        Integer twoPrefix = Integer.parseInt(twoStrPrefix);
        Integer threePrefix = Integer.parseInt(threeStrPrefix);
        sortMap.put(onePrefix, one);
        sortMap.put(twoPrefix, two);
        sortMap.put(threePrefix, three);

        List<Integer> sortList = new ArrayList<>();
        sortList.add(onePrefix);
        sortList.add(twoPrefix);
        sortList.add(threePrefix);
        Collections.sort(sortList);

        StringBuffer buffer = new StringBuffer();
        for (Integer integer : sortList) {
            buffer.append(sortMap.get(integer));
        }
        System.out.println(buffer.toString());
    }

    private static void obtainIntArray(List<Integer> list, String arrStr) {
        String[] array = arrStr.split(",");
        for (String s : array) {
            int item = Integer.parseInt(s);
            list.add(item);
        }
    }


    public Integer[] compareArray(Integer[] list) {
        for (int i = 0; i < list.length; i++) {
            for (int j = 1; j < list.length - i; j++) {
                Integer item;
                Integer nowItem = list[j];
                Integer pre = list[j - 1];
                if (pre > nowItem) {
                    item = pre;
                    list[j - 1] = list[j];
                    list[j] = item;
                }
            }
        }
        return list;
    }


    /*public static void main(String[] args) {
        List<Integer> integers=new ArrayList<>();
        integers.add(5);
        integers.add(8);
        integers.add(3);
        integers.add(1);
        Collections.sort(integers);
        System.out.println(integers);
    }*/

    public static void main(String[] args) {
    /*UserDAO userDAO = (UserDAO) Proxy.newProxyInstance(UserDAO.class.getClassLoader(),
            new Class[]{UserDAO.class}, new DaoProxy());*/
        //List<User> users = userDAO.selectUsers();
        DaoProxyFactory daoProxyFactory = new DaoProxyFactory();
        /*UserDAO userDAO = daoProxyFactory.getDaoProxy(UserDAO.class.getClassLoader(), new Class[]{UserDAO.class}, new DaoProxy());*/
        UserDAO userDAO = daoProxyFactory.getMapper(UserDAO.class);
        Stock stock = new Stock(5, "sw", 0, 8, 1);
        //int row = userDAO.insertUser(stock);
        //int row = userDAO.updateStock(stock);
        int row = userDAO.deleteStock("9");
        //User user = userDAO.selectUser(8);
        System.out.println("res: " + row);
    }
}
